<div class="modal fade" id="login">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span class="glyphicon glyphicon-remove"></span>
        </button>

        <p class="text-muted text-center btn-block btn btn-primary btn-rect">普通用户登录</p>
      </div>
      <div class="modal-body">

        <form class="form-inline text-align"  name="fm" method="post" action="doLogin.php" onsubmit="return check()"
 class="form-horizontal">
          <input type="hidden" name="vid" id="videoid" >
          <div class="form-group " style="padding-left: 170px">
            <label class="sr-only" for="uname">用户名</label>
            <div class="input-group">
              <div class="input-group-addon">
                <span class="glyphicon glyphicon-user"></span>
              </div>
              <input type="text" class="form-control" id="uname" name="uname" placeholder="用户名"></div>
          </div>

          <div class="form-group" style="padding-left: 170px">
            <label class="sr-only" for="pwd">密码</label>
            <div class="input-group">
              <div class="input-group-addon">
                <span class="glyphicon glyphicon-lock"></span>
              </div>
              <input type="password" class="form-control" id="pwd" name="pwd" placeholder="密码"></div>
          </div>
          <div style="padding-top: 30px;text-align:center;">
            <button type="submit" class="btn btn-primary">登陆</button>
            <button type="reset" class="btn btn-danger">重置</button>
          </div>
        </form>

      </div>

    </div>
    <!-- /.modal-content --> </div>
  <!-- /.modal-dialog -->
</div>
<div class="modal fade" id="dologin">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span class="glyphicon glyphicon-remove"></span>
        </button>

        <p class="text-muted text-center btn-block btn btn-primary btn-rect">管理员登录</p>
      </div>
      <div class="modal-body">

        <form class="form-inline text-align"  name="fm" method="post" action="doAdminLogin.php" onsubmit="return check()"
 class="form-horizontal">
          <input type="hidden" name="vid" id="videoid" >
          <div class="form-group " style="padding-left: 170px">
            <label class="sr-only" for="uname">用户名</label>
            <div class="input-group">
              <div class="input-group-addon">
                <span class="glyphicon glyphicon-user"></span>
              </div>
              <input type="text" class="form-control" id="uname" name="username" placeholder="用户名"></div>
          </div>

          <div class="form-group" style="padding-left: 170px">
            <label class="sr-only" for="pwd">密码</label>
            <div class="input-group">
              <div class="input-group-addon">
                <span class="glyphicon glyphicon-lock"></span>
              </div>
              <input type="password" class="form-control" id="pwd" name="pwd" placeholder="密码"></div>
          </div>
          <div style="padding-top: 30px;text-align:center;">
            <button type="submit" class="btn btn-primary">登陆</button>
            <button type="reset" class="btn btn-danger">重置</button>
          </div>
        </form>

      </div>

    </div>
    <!-- /.modal-content --> </div>
  <!-- /.modal-dialog -->
</div>
<!-- /.modal -->

<!-- 修改密码模态框 -->
<div class="modal fade"id="changePassword"tabindex="-1"role="dialog"
aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">修改个人密码</h4>
</div>
<div class="modal-body">
<form
name="fm"  method="post"   action="dochangepassword.php"  onsubmit="return
check()" class="form-horizontal">
<div class="form-group">
<label for="exampleInputPassword1" class="col-md-4 control-label">原密码</label>
<div class="col-md-4">
<input  type="password"   name="old"  class="form-control"   id="exampleInputPassword1"
placeholder="原密码" required>
</div>
<div class="col-md-4">
</div>
</div>
<div class="form-group">
<label for="exampleInputPassword1" class="col-md-4 control-label">新密码</label>
<div class="col-md-4">
<input  type="password" name="new1"  class="form-control"  id="exampleInputPassword1"
placeholder="新密码" required>
</div>
<div class="col-md-4">
</div>
</div>
<div class="form-group">
<label  for="exampleInputPassword1"  class="col-md-4  control-label">确认新 密码
</label>
<div class="col-md-4">
<input  type="password" name="new2"  class="form-control"  id="exampleInputPassword1"
placeholder="确认新密码" required>
</div>
<div class="col-md-4">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="submit" class="btn btn-default" value="修改">
<input type="reset" class="btn btn-default" value="重置">
</div>
</div>
<?php
if(isset($_GET["msg3"])){
echo'<h1 style="color:red;">'.$_GET["msg3"]."</h1>";
}
?>
<?php
if(isset($_GET["msg4"])){
echo'<h1 style="color:red;">'.$_GET["msg4"]."</h1>";
}
?>
<?php
if(isset($_GET["msg5"])){
echo'<h1 style="color:red;">'.$_GET["msg5"]."</h1>";
}
?>
</form>
</div>
<div class="modal-footer">
<button
type="button"
class="btn
btn-default"
onclick="location.replace('index.php')"
data-dismiss="modal">关闭</button>
</div>
</div>
</div>
</div>
<!-- 用户注册模态框 -->
<div class="modal fade" id="userReg" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<buttontype="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">请填写注册用户信息</h4>
</div>

<div class="modal-body">
<form class="form-horizontal "method="post" action="userdoLogin.php" enctype="multipart/form-data">
<div class="form-group">
<label for="exampleInputUserName1" class="col-md-2 control-label">用户名</label>
<div class="col-md-4">
<input  type="text"  name="uname"  class="form-control"  id="exampleInputUserName1"
placeholder="姓名" required>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">密码</label>
    <div class="col-md-4">
    <input type="password"  name="password" class="form-control" placeholder="密码" required="">
  </div>
</div>

<div class="col-md-6">
</div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">性别</label>
    <div class="col-md-4">
    <input type="radio"  name="gender" value="0"checked="">男
    <input type="radio"  name="gender" value="1">女
  </div>
</div>
<div class="form-group">
    <label class="col-md-2  control-label">生日</label>
    <div class="col-md-4">
    <input type="date" name="birthdate">
  </div>
 <div class="form-group">
<label class="col-md-2 control-label">爱好</label>
<div class="col-md-4">
<input type="checkbox" name="hobby[]" value="旅游" >旅游
<input type="checkbox" name="hobby[]" value="登山" >登山
<input type="checkbox" name="hobby[]" value="健身">健身
<input type="checkbox" name="hobby[]" value="上网">上网
<input type="checkbox" name="hobby[]" value="游泳">游泳
  </div>
</div>
<div class="form-group">
    <label class="col-md-2  control-label">学历</label>
    <div class="col-md-4">
    <select name="degree">
<option value="0">请选择</option>
<option value="1">高中</option>
<option value="2">大学</option>
<option value="3">研究生</option>
<option value="4">博士生</option>  
</select>
  </div>
</div>
<div class="form-group">
    <label class="col-md-2 col-xs-5 control-label">自我介绍</label>
    <div class="col-md-4">
    <textarea name="intro">自我简介：</textarea>
  </div>
</div>
<div class="form-group">
    <label class="col-md-2 col-xs-5 control-label">头像</label>
    <div class="col-md-4">
    <input type="file" name="pic">
  </div>
</div>
<div class="col-md-6">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="submit" class="btn btn-default" value="更新">
<input type="reset" class="btn btn-default" value="重置">
</div>
</div>
<?php
if(isset($_GET["msg"])){
echo'<h1 style="color:red;">'.$_GET["msg"]."</h1>";
}
?>
<?php
if(isset($_GET["msg9"])){
echo'<h1 style="color:red;">'.$_GET["msg9"]."</h1>";
}
?>
</form>
</div>
<div class="modal-footer">
<button   type="button"   class="btn   btn-default"   onclick="location.replace('index.php')"
data-dismiss="modal">关闭</button>
</div>
</div>
</div>
</div>
<!-- 修改个人信息模态框 -->

<div class="modal fade"id="edituserReg" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<buttontype="button"class="close"data-dismiss="modal"aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">请填写修改用户信息</h4>
</div>
<div class="modal-body">
<?php 
require_once('./system/dbConn.php');  
connect();
session_start();
   $u = $_SESSION['user'];
   $sql = "select * from users where uname='$u'";
  $rs=mysql_query($sql);
   $row = mysql_fetch_assoc($rs);
   $uname = $row['uname'];
   $id = $row['uid'];
   $gender = $row['gender'];
   $birthdate = $row['birthdate'];
   $hobby = $row['hobby'];
   $degree = $row['degree'];
   $intro = $row['intro'];
   $pic=$row['pic'];

  //将查询结果显示在表单中
 ?>
 <form method=post  action="doUserReg.php"  enctype="multipart/form-data" class="form-horizontal" onsubmit="return check()">
<div class="form-group ">
     <label class="col-md-2 col-xs-5 control-label">UID:</label>
     <div class="col-md-8">
     <input type="text" name="id" class="form-control" placeholder="ID"  value=<?php echo $id; ?> > 
     </div>
  </div> 
<div class="form-group ">
     <label class="col-md-2 col-xs-5 control-label">用户名:</label>
     <div class="col-md-8">
     <input type="text" name="uname" class="form-control" placeholder="姓名" disabled="disabled" value=<?php echo $uname; ?> > 
     </div>
  </div> 

<div class="form-group">
   <label class="col-sm-2 col-sm-offset-2 control-label" >性&nbsp;&nbsp;&nbsp;&nbsp;别</label>
   <div class="col-sm-4">
   <label class="radio-inline">
       <input type="radio" name="gender"  value="0"  <?php if (!$gemder) echo "checked" ;?>>男
   </label>
  <label class="radio-inline">
        <input type="radio" name="gender"  value="1"  <?php if ($gemder) echo "checked" ;?>>女
  </label>
   </div>
</div> 

<div class="form-group">
   <label  class="col-sm-2  col-sm-offset-2 control-label">生&nbsp;&nbsp;&nbsp;&nbsp;日</label>
   <div class="col-sm-4">
     <input type="date" name="birthdate"  class="form-control"  value=<?php echo $birthdate; ?>>
   </div>
</div> 

<div class="form-group">
<label  class="col-sm-2 col-sm-offset-2 control-label">爱&nbsp;&nbsp;&nbsp;&nbsp;好</label>
<div class="col-sm-4">
  <label class="cheaked-inline">
    <input type="checkbox" name="hobby[]" value="旅游" <?php  if(strstr($hobby,'旅游')) echo 'checked';  ?>>旅游
  </label>
   <label class="cheaked-inline">
     <input type="checkbox" name="hobby[]" value="登山" <?php  if(strstr($hobby,'登山')) echo 'checked';  ?>>登山
   </label>
    <label class="cheaked-inline">
     <input type="checkbox" name="hobby[]" value="健身" <?php  if(strstr($hobby,'健身')) echo 'checked';  ?>>健身
   </label>
    <label class="cheaked-inline">
     <input type="checkbox" name="hobby[]" value="上网" <?php  if(strstr($hobby,'上网')) echo 'checked';  ?>>上网
    </label>
    <label class="cheaked-inline">
     <input type="checkbox" name="hobby[]" value="游泳" <?php  if(strstr($hobby,'游泳')) echo 'checked';  ?>>游泳
   </label>
</div>
</div>

<div class="form-group">
<label class="col-sm-2 col-sm-offset-2 control-label text-center" >学&nbsp;&nbsp;&nbsp;&nbsp;历</label>
<div class="col-sm-4">
<select name="degree">
  <option value="0">---请选择---</option>
  <option value="1" <?php  if($degree=='1') echo 'selected';  ?>>高中</option>
  <option value="2" <?php  if($degree=='2') echo 'selected';  ?>>大学</option>
  <option value="3" <?php  if($degree=='3') echo 'selected';  ?>>研究生</option>
  <option value="4" <?php  if($degree=='4') echo 'selected';  ?>>博士生</option>
      </select>
    </div>
  </div>

<div class="form-group">
<label class="col-sm-2 col-sm-offset-2 control-label">自我介绍</label>
<div class="col-sm-4">
<textarea name="intro" cols="40" rows="5"><?php  echo $intro;  ?></textarea>
</div>
</div>

<div class="form-group">
<label class="col-sm-2  col-sm-offset-2 control-label">头&nbsp;&nbsp;&nbsp;&nbsp;像</label>
<div class="col-sm-4">
  <input type="file" name="pic">
  原头像：<img class="img-circle" src="UserPhotoPath.$row['pic']" width=80 height=80 >;
  </div>
  </div>

<div class="form-group">
<div class="col-sm-offset-5 col-sm-4">
<input type="submit" class="btn btn-success" value="更新">
<input type="reset"  class="btn btn-danger"  value="重置">
  </div>
  </div>

  </form>
</div>

<div class="modal-footer">
<button type="button" class="btn btn-default" onclick="location.replace('index.php')"
 data-dismiss="modal">关闭</button>
</div>


</div>
</div>
</div>




<div class="modal fade"id="commentList" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<buttontype="button"class="close"data-dismiss="modal"aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="commentList">留言列表</h4>
</div>
<div class="modal-body">

<?php 
         require_once('inc_admin.php');
          ?>
              
 <?php 
  // validate();
  // var_dump($_SESSION);
  // unset($_SESSION['admin']);
  // var_dump($_SESSION);
  connect();
  //编写sql语句
  $sql = "select * from comments";
  //关键字可能是用户点击搜索按钮得到的，也可能是点击”下一页“超链接得到的
  // var_dump($_REQUEST);

  if($_REQUEST['key'])  {     
      $key = trim($_REQUEST['key']);
      $sql = $sql." where vid like '%{$key}%' ";    
  }
  //获取总行数，用于计算分几页显示
  $result = mysql_query($sql);
  $totalrows = mysql_num_rows($result);

  //获取指定的页码
  $page = $_REQUEST['page'];
  //判断是否指定第几页，如果没有指定，则显示第1页。
  if(!isset($page)) $page = 1;
  //如果用户点击了搜索按钮，则页码也设置第1页
  if($_POST['search'])        $page = 1;
  //定义每页显示的行数
  $rowsperpage = 2;
  //计算从表中第几行开始输出
  $start = ($page-1) * $rowsperpage;

  //查询用户，从第$start行开始，共查询$rowsperpage行。
  $sql .= " limit {$start}, {$rowsperpage}";
  //echo $sql.'<br/>';
  //执行sql语句
  $result = mysql_query($sql) or die('查询失败！'.mysql_error());  
 ?>
 <table align="center" width="80%">
 <tr><td  align="left" >
 <form method=post action="">
    请输入视频名称：
    <input type="text" name="key">
    <input type="submit" name='search' value="搜索">  
 </form> 
 </td></tr>
 </table>

  <table class="table table-hover" > 
 <tr>
   <th>序号</th>
   <th>视频名称</th>   
   <th>留言内容</th>
   <th>留言人</th>
   <th>发表时间</th>
   <th>操作</th>
 </tr>

 <?php
  while($row = mysql_fetch_assoc($result)){
     echo '<tr>';
     echo '<td>'.$row['cid'].'</td>';
     echo '<td>';
      $wsuserid=$row['vid'];
      $sql0="select videoname from videos where vid=$wsuserid";
      $result1=mysql_query($sql0);
        $row1=mysql_fetch_assoc($result1);
        echo $row1["videoname"];
     echo '</td>';
       echo '<td>'.$row['content'].'</td>'; 
        echo '<td>';
      $userid=$row['uid'];
      $sql1="select uname from users where uid=$userid";
      $result2=mysql_query($sql1);
        $row2=mysql_fetch_assoc($result2);
        echo $row2["uname"];
     echo '</td>';
     echo '<td>'.$row['cdate'].'</td>';
     // echo '<td>'.$row['pic'].'</td>';
     // echo '<td>'.$dg.'</td>'; 
     echo '<td><a href="commentEdit.php?cid='.$row['cid'].' ">修改</a> | 
     <a href="commentDelete.php?cid='.$row['cid'].'" onClick="return confirm(\'确定要删除吗？\');">删除</a></td>';
     echo '</tr>';  
  }
  echo '</table>';  
  
  //计算总页数。如果每页显示的行数>总行数，则只有1页，否则，页数=总行数/每页行数，上取整。
  //echo $rowsperpage.', '.$totalrows;
  if($rowsperpage >= $totalrows)
      $totalpages = 1;
  else{   
      $totalpages = ceil($totalrows / $rowsperpage);
  }
  //如果不是第1页，则显示第一页和上一页的超链接，否则只显示文字
  if($page>1){
      $first = "<a href=?page=1&key={$key}>第一页</a>";
      $pre = "<a href=?page=".($page-1)."&key={$key}>上一页</a>";
  }else{
      $first = '首页';
      $pre = '上一页';
  }
  //如果不是最后一页，则显示下一页和最后一页的超链接，否则只显示文字
  if($page<$totalpages){
      $last = "<a href=?page=$totalpages&key={$key}>尾页</a>";
      $next = "<a href=?page=".($page+1)."&key={$key}>下一页</a>";
  }else{
      $last = '尾页';
      $next = '下一页';
  }
  echo "<table align='center'><tr>";
  echo "<td>共{$totalrows}条记录</td>";
  echo "<td>$first"."&nbsp;&nbsp;"."$pre"."&nbsp;&nbsp;";
  for($i=1;$i<=$totalpages;$i++) {
        echo "<a href='?page=$i&key={$key}'>第{$i}页</a>&nbsp;&nbsp;";
  }
  echo "$next"."&nbsp;&nbsp;"."$last &nbsp;";
  //输出第几页/共几页
  echo "<font color=red>";
  echo "第".$page."页/共".$totalpages."页";
  echo "</font></td>";
  //输出转到几页的表单
  ?>

  <td>
  <form method=post action="">
  <input type="text" name="page" placeholder="跳转页数" size=2>
  <input type="submit" value="转到">  
  </form>
  </td>
  <div class="modal-footer">
<button type="button" class="btn btn-default" onclick="location.replace('index.php')"
 data-dismiss="modal">关闭</button>
</div>
  </tr>
  </table>
   </div>
   </div>
   </div>
   <hr />
  </div>
